<template>
    <rx-layout>
        <div slot="center" style="padding: 15px">
            <rx-fit>
                <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
                    <div class="table-operator">
                        <rx-button alias="formLiteFlowDelete" :butn-icon="'delete'" :butn-type="'danger'"
                                   v-if="removeEnable && selectedRowKeys.length > 0"
                                   :show-no-right="false" @click="delByIds(selectedRowKeys)">
                            {{ $ti18('rxList.delBtn', '删除') }}
                        </rx-button>
                    </div>
                </div>
                <rx-grid
                    ref="table"
                    :allowRowSelect="true"
                    :multiSelect="true"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formLiteFlowLog/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="id"
                    @selectChange="onSelectChange"
                >
                    <span slot="status" slot-scope="{ text, record }">
                        <a-tag :color="statusMap[text].color">
                          <span>{{ statusMap[text].text }}</span>
                        </a-tag>
                    </span>
                    <span slot="action" slot-scope="{ text, record }" class="actionIcons" :size="2">
                        <span @click="detail(record)">{{$ti18('rxList.detailBtn','明细')}}</span>
                        <span @click="delByIds([record.id])">{{ $ti18('rxList.delBtn', '删除') }}</span>
                    </span>
                </rx-grid>
            </rx-fit>
        </div>
    </rx-layout>
</template>

<script>
import FormLiteFlowLogApi from '@/api/form/core/formLiteFlowLog.js'
import {BaseList, RxFit, RxGrid, Util} from "@lowcode/jpaas-common-lib";
import FormLiteFlowLogDetail from "./FormLiteFlowLogDetail.vue";


export default {
    name: 'FormLiteFlowLogList',
    mixins: [BaseList],
    props: ["liteFlowId"],
    components: {
        RxFit,
        RxGrid,
    },
    data() {
        return {
            columns: [
                {
                    title: this.$ti18('rxList.index', '序号'),
                    type: 'indexColumn',
                    width: 60,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: this.i18n('executionTime', '执行时间'), dataIndex: 'createTime', width: 100},
                {title: this.i18n('executor', '执行人'), dataIndex: 'createByName', width: 100},
                {title: this.i18n('rule', '规则'), dataIndex: 'rule', width: "50%"},
                {title: this.$comi18('rxDialog.status', '状态'), dataIndex: 'status', width: 80, scopedSlots: {customRender: 'status'}},
                {
                    title: this.$ti18('rxList.action', '操作'),
                    width: 100,
                    dataIndex: 'action',
                    scopedSlots: {customRender: 'action'}
                }
            ],
            statusMap: {
                1: {color: 'green', text: this.i18n('success',"成功")},
                0: {color: 'red', text: this.i18n('fail',"失败")},
            },
        }
    },
    created() {
        this.queryParam.Q_LITE_FLOW_ID__S_EQ = this.liteFlowId;
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"formLiteFlow",key);
        },
        delById(ids) {
            return FormLiteFlowLogApi.del({ids: ids.join(',')});
        },
        detail(record){
            Util.open({
                curVm:this,
                max:true,
                title:this.i18n('logDetail',"日志明细"),
                component:FormLiteFlowLogDetail,
                data:{
                    logs : record.logs
                }
            })

        }
    }
}
</script>
<style scoped>
</style>

